package org.example.http.demo;

import com.google.gson.Gson;
import org.example.http.HttpServletImpl;
import org.example.http.HttpServletRequest;
import org.example.http.HttpServletResponse;
import org.example.http.ServletException;

import java.io.IOException;
import java.util.Map;

public class LogoutServlet extends HttpServletImpl {
    Gson gson = new Gson();
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        request.getSession().invalidate();
        response.sendRedirect("/login.html");
        // 禁止缓存
//        response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
//        response.setHeader("Pragma", "no-cache");
//        response.setHeader("Expires", "0");
//        response.setContentType("text/html;charset=utf-8");
//        gson.toJson("logout success", response.getWriter());
//        response.getWriter().flush();
    }
}
